package com.atguigu.condition;

import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.env.Environment;
import org.springframework.core.type.AnnotatedTypeMetadata;

/**
 * Copyright 2025 ZS Network Co., Ltd. All rights reserved.
 * 本文件仅限于正数网络技术有限公司内部传阅，禁止外泄以及用于其他的商业目的。
 * Created by zwn on 2025/7/29.
 *
 * @description:
 */
public class WindowsCondition implements Condition {

    /**
     * ConditionContext 判断条件能使用的上下文信息
     * AnnotatedTypeMetadata 注释信息
     * @param context the condition context
     * @param metadata metadata of the {@link org.springframework.core.type.AnnotationMetadata class}
     * or {@link org.springframework.core.type.MethodMetadata method} being checked.
     * @return
     */
    @Override
    public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {

        //return context.getEnvironment().getProperty("os.name").contains("Windows");
        ConfigurableListableBeanFactory beanFactory = context.getBeanFactory();
        BeanDefinitionRegistry registry = context.getRegistry();
        Environment environment = context.getEnvironment();
        boolean b = environment.getProperty("os.name").contains("Windows");
        return b;
    }
}
